package com.sz.stock.client;

import com.sz.stock.common.PageBean;
import com.sz.stock.common.ResultBean;
import com.sz.stock.model.Bankcard;
import com.sz.stock.model.Moneytrad;
import com.sz.stock.model.TUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.TimeoutException;

@Component
@FeignClient("stock-user")
public interface UserClient {

    @RequestMapping(value = "/user/testConnection")
    void testConnection();

    @RequestMapping(value = "/user/register")
    ResultBean register(@RequestBody TUser user);

    @RequestMapping(value = "/user/openAccount")
    ResultBean openAccount(@RequestBody TUser user, @RequestParam("bankCardNumber") String bankCardNumber);

    @RequestMapping(value = "/user/recharge")
    ResultBean recharge(BigDecimal money);

    @RequestMapping(value = "/user/login")
    ResultBean resultLogin(@RequestParam("userphone")String userphone,@RequestParam("userpwd") String userpwd);

    @RequestMapping(value = "/user/sendCode")
    String sendCode(@RequestParam("userphone")String userphone) throws Exception;

    @RequestMapping(value = "/user/resetPassword")
    ResultBean resetPassword(@RequestParam("userphone")String userphone,@RequestParam("userupwd")String userupwd,@RequestParam("usercode")String usercode);

    @RequestMapping(value = "/user/opencode")
    Boolean openCode(@RequestParam("code") String code);

    @RequestMapping(value = "/user/usermoney")
    List<TUser> getAllmoney(@RequestParam("userid") int userid);

    @RequestMapping(value = "/user/topup")
    ResultBean topup(@RequestParam("userid") int userid,@RequestParam("balance") BigDecimal balance);

    @RequestMapping(value = "/user/withdraw")
    ResultBean withdraw(@RequestParam("userid") int userid,@RequestParam("balance") BigDecimal balance);

    @RequestMapping(value = "/user/modification")
    ResultBean Modification(@RequestParam("userid") int userid,@RequestParam("olduserpwd")String olduserpwd,@RequestParam("newuserpwd")String newuserpwd);

    @RequestMapping(value = "/user/modifyname")
    ResultBean ModifName(@RequestParam("userid") int userid,@RequestParam("username") String username);

    //用过用户ID 查询 银行卡信息
    @RequestMapping("/user/selectBankCardByUserID")
    Bankcard selectBankCardByUserID(@RequestParam(value = "userid" ,required = false) int userid);


    /**
     * 根据userid查询银行卡；
     */
    @RequestMapping(value = "/user/sBankCard")
    ResultBean searchBankCard(@RequestParam("userid") String userid);


    //通过 用户ID 查询 用户信息
    @RequestMapping(value = "/user/selectTUserByUserID")
    TUser selectTUserByUserID(@RequestParam(value = "userid" ,required = false) int userid);


    @RequestMapping(value = "/user/list")
    PageBean<Moneytrad> getAllCarByid(@RequestParam("userid") int userid, @RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize);
}
